package com.qpkj.web.controller.oms;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.qpkj.common.annotation.Log;
import com.qpkj.common.core.controller.BaseController;
import com.qpkj.common.core.domain.AjaxResult;
import com.qpkj.common.enums.BusinessType;
import com.qpkj.oms.domain.OmsStockRecoder;
import com.qpkj.oms.service.IOmsStockRecoderService;
import com.qpkj.common.utils.poi.ExcelUtil;
import com.qpkj.common.core.page.TableDataInfo;

/**
 * 库存记录Controller
 *
 * @author ruoyi
 * @date 2022-12-20
 */
@RestController
@RequestMapping("/oms/taskrecoder")
public class OmsStockRecoderController extends BaseController {
    @Autowired
    private IOmsStockRecoderService omsStockRecoderService;

    /**
     * 查询库存记录列表
     */
    //@PreAuthorize("@ss.hasPermi('oms:taskrecoder:list')")
    @GetMapping("/list")
    public TableDataInfo list(OmsStockRecoder omsStockRecoder) {
        startPage();
        List<OmsStockRecoder> list = omsStockRecoderService.selectOmsStockRecoderList(omsStockRecoder);
        return getDataTable(list);
    }

    /**
     * 导出库存记录列表
     */
   // @PreAuthorize("@ss.hasPermi('oms:taskrecoder:export')")
    @Log(title = "库存记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OmsStockRecoder omsStockRecoder) {
        List<OmsStockRecoder> list = omsStockRecoderService.selectOmsStockRecoderList(omsStockRecoder);
        ExcelUtil<OmsStockRecoder> util = new ExcelUtil<OmsStockRecoder>(OmsStockRecoder.class);
        util.exportExcel(response, list, "库存记录数据");
    }

    /**
     * 获取库存记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('oms:taskrecoder:query')")
    @GetMapping(value = "/{recoderId}")
    public AjaxResult getInfo(@PathVariable("recoderId") Long recoderId) {
        return success(omsStockRecoderService.selectOmsStockRecoderByRecoderId(recoderId));
    }

    /**
     * 新增库存记录
     */
    @PreAuthorize("@ss.hasPermi('oms:taskrecoder:add')")
    @Log(title = "库存记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OmsStockRecoder omsStockRecoder) {
        return toAjax(omsStockRecoderService.insertOmsStockRecoder(omsStockRecoder));
    }

    /**
     * 修改库存记录
     */
    @PreAuthorize("@ss.hasPermi('oms:taskrecoder:edit')")
    @Log(title = "库存记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OmsStockRecoder omsStockRecoder) {
        return toAjax(omsStockRecoderService.updateOmsStockRecoder(omsStockRecoder));
    }

    /**
     * 删除库存记录
     */
    @PreAuthorize("@ss.hasPermi('oms:taskrecoder:remove')")
    @Log(title = "库存记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{recoderIds}")
    public AjaxResult remove(@PathVariable Long[] recoderIds) {
        return toAjax(omsStockRecoderService.deleteOmsStockRecoderByRecoderIds(recoderIds));
    }
}
